package com.exam.controller;

import com.exam.entity.common.ResponseResult;
import com.exam.service.*;
import com.exam.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
public class OtherController {


    @Autowired
    @Qualifier("sysUserServiceImpl")
    private SysUserService sysUserService;
    @Autowired
    @Qualifier("singleChoiceQServiceImpl")
    private SingleChoiceQService singleChoiceQService;
    @Autowired
    @Qualifier("judgmentQServiceImpl")
    private JudgmentQService judgmentQService;

    @Autowired
    @Qualifier("shortAnswerQServiceImpl")
    private ShortAnswerQService shortAnswerQService;
    @Autowired
    @Qualifier("examPaperServiceImpl")
    private ExamPaperService examPaperService;

    @Autowired
    @Qualifier("resourceServiceImpl")
    private ResourceService resourceService;

    ResponseResult responseResult=new ResponseResult();


    @RequestMapping("/question")
    public String question(){
        return "views/manage/question";
    }
    @RequestMapping("/online_exam")
    public String online_exam(){
        return "views/user/online_exam";
    }
    @RequestMapping("/score")
    public String score(){
        return "views/user/score";
    }
    @RequestMapping("/error_question")
    public String error_question(){
        return "views/user/error_question";
    }

    @RequestMapping("/score_statistics")
    public String score_statistics(){
        return "views/manage/score_statistics";
    }

    @RequestMapping("/wait_review_exam")
    public String wait_review_exam(){
        return "views/manage/wait_review_exam";
    }

    @RequestMapping("/welcome")
    public String welcome(){
        return "views/manage/welcome";
    }

    @RequestMapping("/system_data")
    @ResponseBody
    public String system_data() {
        //单选题
        int num1 = singleChoiceQService.num1();
        //判断题
        int num2 = judgmentQService.num2();
        //简答题
        int num3 = shortAnswerQService.num3();
        //试卷数
        int num4 = examPaperService.num4();
        //用户数
        int num5 = sysUserService.num5();
        //学习资源数
        int num6 = resourceService.num6();

        Map<String,Integer> map=new HashMap<>();
        map.put("cq_num",num1);
        map.put("jq_num",num2);
        map.put("saq_num",num3);
        map.put("paper_num",num4);
        map.put("user_num",num5);
        map.put("resource",num6);

        responseResult.setCode(200);
        responseResult.setMessage("成功");
        responseResult.setResult(map);
        return JsonUtils.getJson(responseResult);
    }

    @RequestMapping("/online_test")
    public String online_test(){
        return "views/user/online_test";
    }
}
